﻿#include "needupdateappcomputerwidget.h"
#include "ui_needupdateappcomputerwidget.h"
#include "qfiledialog.h"

#define NEED_UPDATE_APP_COMPUTER_WIDGET_WIDTH 210
#define NEED_UPDATE_APP_COMPUTER_WIDGET_HEIGHT 160

NeedUpdateAppComputerWidget::NeedUpdateAppComputerWidget(Computer &computer, QWidget *parent) :
    QWidget(parent),
    ui(new Ui::NeedUpdateAppComputerWidget)
{
    ui->setupUi(this);

    this->setMinimumSize(NEED_UPDATE_APP_COMPUTER_WIDGET_WIDTH,NEED_UPDATE_APP_COMPUTER_WIDGET_HEIGHT);
    this->setMaximumSize(NEED_UPDATE_APP_COMPUTER_WIDGET_WIDTH,NEED_UPDATE_APP_COMPUTER_WIDGET_HEIGHT);

    setComputer(computer);
}

NeedUpdateAppComputerWidget::~NeedUpdateAppComputerWidget()
{
    delete ui;
}

void NeedUpdateAppComputerWidget::setComputer(Computer &computer)
{
    this->computer = computer;

    ui->nameLabel->setText(this->computer.name);

    if(this->computer.isOffLine())
    {
        ui->statusImageWidget->setStyleSheet("QWidget{border-image: url(:/new/icon/ui/computer_bad.png);}");
    }
    else if(this->computer.unReadALarmCount > 0)
    {
        ui->statusImageWidget->setStyleSheet("QWidget{border-image: url(:/new/icon/ui/computer_warn.png);}");
    }
    else
    {
        ui->statusImageWidget->setStyleSheet("QWidget{border-image: url(:/new/icon/ui/computer_good.png);}");
    }

    ui->statusTextEdit->setPlainText("ip:" + this->computer.ip + "\n连接状态:" + this->computer.getOffLineState() + "\n有未读异常:"
                                    + int2QStr(this->computer.unReadALarmCount) + "条");
}

void NeedUpdateAppComputerWidget::on_updatePushButton_clicked()
{

}

void NeedUpdateAppComputerWidget::on_checkBox_stateChanged(int arg1)
{
    if(arg1 == Qt::Checked)
    {

    }
}
